home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / zendisk2.zip / LST13-1.ASM < prev    next >
Assembly Source File  |  1990-02-15  |  1KB  |  49 lines

  1. ;
  2. ; *** Listing 13-1 ***
  3. ;
  4. ; Generates the cumulative exclusive-or of all bytes in a
  5. ; 64-byte block of memory by using the LOOP instruction to
  6. ; repeat the same code 64 times.
  7. ;
  8.     jmp    Skip
  9. ;
  10. ; The 64-byte block for which to generate the cumulative
  11. ; exclusive-or.
  12. ;
  13. X=1
  14. ByteArray    label    byte
  15.     rept    64
  16.     db    X
  17. X=X+1
  18.     endm
  19. ;
  20. ; Generates the cumulative exclusive-or of all bytes in a
  21. ; 64-byte memory block.
  22. ;
  23. ; Input:
  24. ;    SI = pointer to start of 64-byte block for which to
  25. ;        calculate cumulative exclusive-or
  26. ;
  27. ; Output:
  28. ;    AH = cumulative exclusive-or of all bytes in the
  29. ;        64-byte block
  30. ;
  31. ; Registers altered: AX, CX, SI
  32. ;
  33. CumulativeXor:
  34.     cld
  35.     sub    ah,ah    ;initialize our cumulative XOR to 0
  36.     mov    cx,64    ;number of bytes to XOR together
  37. XorLoop:
  38.     lodsb        ;get the next byte and
  39.     xor    ah,al    ; XOR it into the cumulative result
  40.     loop    XorLoop
  41.     ret
  42. ;
  43. Skip:
  44.     call    ZTimerOn
  45.     mov    si,offset ByteArray
  46.                 ;point to the 64-byte block
  47.     call    CumulativeXor    ;get the cumulative XOR
  48.     call    ZTimerOff
  49.